package com.example.stuwork.service.impl;

import com.example.stuwork.dao.AdminDao;
import com.example.stuwork.pojo.Admin;
import com.example.stuwork.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 管理员服务实现类
 */
@Service
public class AdminServiceImpl implements AdminService {
    
    @Autowired
    private AdminDao adminDao;
    
    @Override
    public Admin getById(Long adminId) {
        return adminDao.getById(adminId);
    }
    
    @Override
    public Admin getByUsername(String username) {
        return adminDao.getByUsername(username);
    }
    
    @Override
    public boolean updateAdmin(Admin admin) {
        // 确保adminId不为空
        if (admin.getAdminId() == null) {
            return false;
        }
        // 调用DAO层更新，返回影响的行数>0表示更新成功
        return adminDao.update(admin) > 0;
    }
} 